package com.byit.controller;

import com.byit.domain.AppApplication;
import com.byit.log.ChannelType;
import com.byit.log.Log;
import com.byit.log.OperatorType;
import com.byit.msg.MessageResult;
import com.byit.solr.ISolrService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.configurationprocessor.json.JSONObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 查找
 *
 * @author tjm
 * @date 2019/1/11.
 */
@RestController
@RequestMapping("/api/search")
public class SearchController {

    @Autowired
    private ISolrService<AppApplication> solrService;

    @Log(title = "搜索", operate = OperatorType.DATA_SELECT, channel = ChannelType.WEB_INTER)
    @GetMapping("/select")
    public Object select(String title, Integer page, Integer limit){
        try {
            JSONObject param = new JSONObject();
            param.put("title",title);
            param.put("page",page);
            param.put("limit",limit);
            return MessageResult.success(solrService.select(param));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
